<template>
  <div>
    <div class="strategy">
      <h4>相关攻略</h4>
      <div class="content" v-for="(value, index) in dataList" :key="index">
        <div class="on_img" v-if="value.images.length == 0">
          <div>{{ value.title }}</div>
          <span>{{ value.created_at | dateForm }}</span
          ><span>阅读</span> <span>{{ value.account }}</span>
        </div>
        <div class="img" v-if="value.images.length != 0">
          <div class="div">
            <img :src="value.images[0]" alt="" />
          </div>
          <div class="title">
            <div>{{ value.title }}</div>
            <span>{{ value.created_at | dateForm }}</span
            ><span>阅读</span> <span>{{ value.account }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";
export default {
  data() {
    return {
      dataList: [],
    };
  },
  mounted() {
    this.$axios({
      url: "posts/recommend",
      params: { id: this.$route.query.id },
    }).then((res) => {
      console.log(res);
      this.dataList = res.data.data;
    });
  },
  // 处理时间
  filters: {
    dateForm(el) {
      return moment(el).format("YYYY-MM-DD HH:mm");
    },
  },
};
</script>

<style lang="less" scoped>
.strategy {
  h4 {
    height: 35px;
    border-bottom: 1px solid #ccc;
    color: #666;
    line-height: 35px;
  }
  .on_img {
    height: 70px;
    padding: 20px 0;
    width: 300px;
    border-bottom: 1px solid #ccc;
    div {
      height: 45px;
      font-size: 14px;
    }
    span {
      color: #666;
      font-size: 12px;
      margin-right: 10px;
    }
  }
  .img {
    display: flex;
    height: 70px;
    padding: 20px 0;
    border-bottom: 1px solid #ccc;
    .div {
      margin-right: 10px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .title {
      width: 2000px;
      div {
        margin-bottom: 10px;
        font-size: 14px;
      }
      span {
        color: #ccc;
        font-size: 12px;
      }
    }
  }
}
</style>